/*************************************************************************
	> File Name: stdin2stdout.c
	> Author: KyleShaw
	> Mail: xtk621@gmail.com 
	> Created Time: 2014-11-27 21:35:33
 ************************************************************************/

#include <stdio.h>
#include <apue.h>

#define BUFSIZE 4096

int main(void)
{
	int input_size, output_size;
	char buf[BUFSIZ];
	input_size = 0;
	output_size = 0;

	while((input_size=read(STDIN_FILENO, buf, BUFSIZ)) > 0) {
		output_size = write(STDOUT_FILENO, buf, input_size);
		if ( output_size != input_size) {
			err_sys("write error");
		}
	}
	if (input_size < 0) {
		err_sys("read error");
	}
}
